import java.util.Arrays;

public class LCP18 {
    public static int breakfastNumber(int[] staple, int[] drinks, int x) {
        Arrays.sort(staple);
        Arrays.sort(drinks);
        int count = 0;
        int size1 = 0;
        int size2 = drinks.length - 1;
        while (size1 < staple.length) {
            int cur = x - staple[size1];
            while (size2 >= 0 && drinks[size2] > cur) {
                size2--;
            }
            if(size2 < 0) {
                break;
            }
            count += (size2 + 1);
            count %= 1000000007;
            size1 ++;
        }
        return count;
    }
}
